package com.lmy.mallback.service.impl;

import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lmy.mallback.entity.Admin;
import com.lmy.mallback.mapper.AdminMapper;
import com.lmy.mallback.service.AdminService;
import com.lmy.mallback.util.EmailUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
* @author lmy
* @description 针对表【t_bigtype】的数据库操作Service实现
* @createDate 2023-01-11 13:54:52
*/
@Service
@Slf4j
public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements AdminService {

    @Autowired
    private AdminMapper adminMapper;

    @Override
    public Admin saveAdmin(Admin admin) {
        Admin dbAdmin = getOne(new UpdateWrapper<Admin>().eq("userName", admin.getUserName()));
        if(dbAdmin !=null){
            throw new RuntimeException("用户已注册");
        }
        save(admin);
        return admin;
    }

}




